home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-in_the_mag-
/
javascript
/
part5
/
scripts
/
random150.js
< prev
next >
Wrap
Text File
|
2000-02-07
|
955b
|
48 lines
<HTML>
<HEAD>
<TITLE>Random Number Generator</TITLE>
<script language="JavaScript">
<!--
function RandomNumber(upper_limit)
{
// This function returns a random number between 0 and upper_limit,
// inclusive, where upper_limit is a parameter passed to the function.
// Alternatively, you could easily modify this function to
// assign upper_limit within the function itself.
return Math.round(upper_limit * Math.random());
}
//-->
</script>
</HEAD>
<BODY>
<script language="JavaScript">
<!--
// The following code demonstrates the use of the RandomNumber() function
// defined above in the HEAD section.
var upper_limit = 50;
document.write('Here is a random number between 0 and ' + upper_limit + ':<br><br>');
document.write(RandomNumber(upper_limit) + '<br><br>');
document.write('Press your browser\'s Reload or Refresh button to see another random number between 0 and ' + upper_limit + '.');
//-->
</script>
</BODY>
</HTML>